<?php
/*
<!--友情链接页面-->
Template Name: 友情链接
*/
get_header();//网站头部 ?>
<!--来源于single.php-->
<div class="single-bj" style="background-image: url(<?php
					$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
					echo $full_image_url[0];?>); background-repeat:round;">
	<div class="single-main-header">
		
<!--文章标题-->
		<div class="single-title"><?php the_title(); ?></div>
		
	<!--博文附加内容-->
		<div class="single-meta">  
							
								<!--时间：--><?php the_time( 'Y.m.d' ); ?>
								<!--类别：--><span>• </span><?php the_category(','); ?>&nbsp;
								<!--阅览次数-->阅读：<?php post_views(' ', ' 次'); ?>
								<!--功能菜单--><?php edit_post_link('编辑', ' <span>&nbsp;</span> ', '' ); ?>
		</div>
	</div>
</div>








<!-- 友情链接 -->
<div class="page-links">
    <?php
    function get_the_link_items($id = null)
    {
        $bookmarks = get_bookmarks('orderby=date&category=' . $id);
        $default_ico = 'https://s.w.org/favicon.ico?2';
        $output = '';
        if (!empty($bookmarks)) {
            $output .= '<ul>';
            foreach ($bookmarks as $bookmark) {
                $output .= '<li><img src="' . $bookmark->link_url . '/favicon.ico" onerror="javascript:this.src=\'' . $default_ico . '\'" /><a href="' . $bookmark->link_url . '" title="' . $bookmark->link_description . '" target="_blank" >' . $bookmark->link_name . '</a></li>';
            }
            $output .= '</ul><div class="clear"></div>';
        }
        return $output;
    }

    $linkcats = get_terms('link_category');
    if (!empty($linkcats)) {
        foreach ($linkcats as $linkcat) {
            $result .= '<h1>' . $linkcat->name . '</h1>';
            if ($linkcat->description) $result .= '<blockquote>' . $linkcat->description . '</blockquote>';
            $result .= get_the_link_items($linkcat->term_id);
        }
    } else {
        $result = get_the_link_items();
    }
    echo $result;
    ?>
</div>

<div class="page-links-h">
想表达什么？
</div>

<?php get_footer(); ?>